﻿using Microsoft.SharePoint;
using System;
using System.ComponentModel;
using System.Web.UI.WebControls.WebParts;

namespace Portal
{
    [ToolboxItemAttribute(false)]
    public partial class CustomerSpeakDetails : WebPart
    {
        // Uncomment the following SecurityPermission attribute only when doing Performance Profiling on a farm solution
        // using the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
        // for production. Because the SecurityPermission attribute bypasses the security check for callers of
        // your constructor, it's not recommended for production purposes.
        // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
        public CustomerSpeakDetails()
        {
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            InitializeControl();
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            SPWeb web = SPContext.Current.Web;
            SPList customerSpeak = web.GetList("/Lists/CustomerSpeak/");
            SPListItem speakItem = customerSpeak.GetItemById(Convert.ToInt32(Page.Request.Params["ID"]));

            if (speakItem != null)
            {
                string speakTitle = speakItem["Title"].ToString();
                string speakDescription = speakItem["Description"].ToString();
                string speakUser = speakItem["SpeakUserName"].ToString();
                string speakDate = "On " + Convert.ToDateTime(speakItem["SpeakDate"].ToString()).ToString("MMM dd, yyyy");

                //lblCustomerTitle.Text = speakTitle;
                lblCustomerDescription.Text = speakDescription;
                lblCustomerName.Text = speakUser.Split('#')[1];
                lblCustomerDate.Text = speakDate;
            }

        }
    }
}
